package self.cloud.domain;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

@SpringBootApplication
@EnableScheduling
public class SelfCloudDomainApplication {
    private static final Logger logger = LoggerFactory.getLogger(SelfCloudDomainApplication.class);

    public static void main(String[] args) throws IOException, AWTException {
        logger.info("SelfCloud Domain Application starting...");
        // 使用这种方法启动SpringBoot，是必须关闭headless
        new SpringApplicationBuilder(SelfCloudDomainApplication.class).headless(false).run(args);

        SystemTray systemTray = SystemTray.getSystemTray();

        URL url = new ClassPathResource("static/connectdevelop-brands.png").getURL();
        BufferedImage image = ImageIO.read(url);
        TrayIcon trayIcon = new TrayIcon(image, "SelfCloud Domain");
        trayIcon.setToolTip("SelfCloud Domain");
        systemTray.add(trayIcon);
    }
}